﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConsoleApplication1.segments.field;

namespace ConsoleApplication1.segments.data_type
{
    class CM_PARENT_RESULT
    {
        public CE Observation_Identifier { get; set; }
        public StringBuilder Sub_ID { get; set; }
        public CE Result { get; set; }

        public int fill(string source, int temp)
        {
            int i, x = 0;
            for (i = temp; i < source.Length; i++)
            {
                if (source[i] == '^')
                    x++;
                else if (source[i] == '|')
                {
                    Sub_ID.Capacity = Sub_ID.Length;
                    return i;
                }

                else if (x == 0)
                {
                    if (Observation_Identifier == null)
                        Observation_Identifier = new CE();
                    i = Observation_Identifier.fill(source, i);
                }
                else if (x == 1)
                {
                    if (Sub_ID == null)
                        Sub_ID = new StringBuilder();
                    Sub_ID.Insert(Sub_ID.Length, source[i]);
                }
                else if (x == 2)
                {
                    if (Result == null)
                        Result = new CE();
                    i = Result.fill(source, i);
                }              
            }
            return i;
        }
    }
}
